<?php

namespace app\webapi\controller;

use app\webapi\common\BaseController;
use app\webapi\vms\service\StatisticsService;
use app\webapi\vms\validate\StatisticsValidate;
use think\App;

/**
 * @统计控制器
 */
class StatisticsController extends BaseController
{
    /**
     * @var StatisticsValidate
     */
    protected $validate;

    /**
     * @var StatisticsService
     */
    protected $service;

    /**
     * @param App $app
     */
    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->validate = new StatisticsValidate();
        $this->service = new StatisticsService();
    }

    /**
     * @desc 获取今日访问统计数据
     * @return \think\response\Json
     * @throws \think\db\exception\DbException
     * @author zhaozhiwei
     * @time 2023/12/14-14:28
     */
    public function getTodayVisitStatisticsDate(){
        $params = $this->validate->goCheck('getTodayVisitStatisticsDate');
        $res = $this->service->getTodayVisitStatisticsDate($this->website_id);
        return $this->responseSuccess($res);
    }

    /**
     * @desc 获取历史访问数据
     * @return \think\response\Json
     * @author zhaozhiwei
     * @time 2023/12/14-14:38
     */
    public function getHistoryVisitListByMouth(){
        $params = $this->validate->goCheck('getHistoryVisitListByMouth');
        $res = $this->service->getHistoryVisitListByMouth($this->website_id,$params['type']);
        return $this->responseSuccess($res);
    }

    /**
     * @desc 获取健康监测列表
     * @return \think\response\Json
     * @author zhaozhiwei
     * @time 2023/12/14-15:48
     */
    public function getHealthExaminationList(){
        $res = $this->service->getHealthExaminationList($this->website_id);
        return $this->responseSuccess($res);
    }
}